package com.ewanghuiju.app.ui.my.adapter;

import android.text.TextUtils;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ewanghuiju.app.R;
import com.ewanghuiju.app.model.bean.response.RedBeanDetailsResponBean;
import com.ewanghuiju.app.util.StringUtil;

import androidx.core.content.ContextCompat;

/**
 * @author sj  qq:751943509
 * @class describe
 * @time 2020/2/20
 */
public class RedBeanListAdapter extends BaseQuickAdapter<RedBeanDetailsResponBean, BaseViewHolder> {
    public RedBeanListAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, RedBeanDetailsResponBean item) {
        helper.setText(R.id.tv_title, TextUtils.isEmpty(item.getRemake()) ? "" : item.getRemake());
        helper.setText(R.id.tv_time, TextUtils.isEmpty(item.getCreate_time()) ? "" : item.getCreate_time());
        TextView tvMoney = helper.getView(R.id.tv_money);
        if (StringUtil.getFloatByString(item.getPrice()) > 0) {
            tvMoney.setTextColor(ContextCompat.getColor(mContext, R.color.colorPrimary));
            tvMoney.setText("+" + item.getPrice() + "");
        } else {
            tvMoney.setTextColor(ContextCompat.getColor(mContext, R.color.color_0abc12));
            tvMoney.setText(item.getPrice() + "");
        }
    }
}
